<?php

namespace App\Lib;

use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Request;
use Illuminate\Support\Str;

class SdSdk
{
    public $client;
    public function __construct(){
        $this->client = new Client();
    }

    //获取小红书的token
   public function test($path){

       $headers = [
           'Referer' => 'http://ai.gomire.com:28000/tagger.html',
//           'Cookie' => $this->cookie,
           'User-Agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36'
       ];
       $options = [
           'json' => [
               'batch_input_recursive' => false,
               'batch_output_action_on_conflict' => 'copy',
               'escape_tag' => true,
               'interrogator_model' => "wd14-convnextv2-v2",
               'path' => 'J:/s麦小图1/' . $path,
               'replace_underscore' => true,
               'threshold' =>0.5
           ],
           "verify" => false
       ];
       $request = new Request('POST', 'http://ai.gomire.com:28000/api/interrogate', $headers);
       $res = $this->client->sendAsync($request, $options)->wait();
       return json_decode($res->getBody(), true);
   }
}
